//引入xylj.js
import request from './xylj'



//封装登录接口
export function LoginApi(data) {
    return request({
        url: '/login',
        method: 'POST',
        data
    })
}

//封装权限列表接口
export function Power() {
    return request({
        url: '/menus',
        method: 'GET',
    })
}

//请求用户列表数据
export function Listuser(params) {
    return request({
        url: '/users',
        method: 'GET',
        params
    })
}

//分装添加用户
export function addUser(data) {
    return request({
        url: '/users',
        method: 'POST',
        data
    })

}

//封装删除
export function delUser(data) {
    return request({
        url: '/users/' + data,
        method: 'Delete',
        data
    })
}

//封装编辑用户
export function eDit(id, data) {
    return request({
        url: `/users/${id}`,
        method: 'PUT',
        data
    })
}

//分装状态接口
export function zTai(data) {
    return request({
        url: '/users/' + data.uId + '/state/' + data.mg_state,
        method: 'PUT',
        data
    })
}
//角色列表接口
export function zscJs() {
    return request({
        url: 'roles',
        method: 'GET',

    })
}

export function zscJslist(id, rid) {
    return request({
        url: `/users/${id}/role`,
        method: 'PUT',
        data: { rid }

    })
}

//权限列表接口
export function getQx(type = 'list') {
    return request({
        url: `/rights/${type}`,
        method: 'GET',
    })
}

//删除权限接口
export function getDelqx(roleId, rightId) {
    return request({
        url: `/roles/${roleId}/rights/${rightId}`,
        method: 'delete',
    })
}


//添加角色接口
export function addJs(data) {
    return request({
        url: `/roles`,
        method: 'post',
        data
    })
}


// export function delUser(data) {
//     return request({
//         url: '/users/' + data,
//         method: 'Delete',
//         data
//     })
// }


//删除角色接口
export function delJs(data) {
    return request({
        url: '/roles/' + data,
        method: 'delete',
        data
    })
}

//编辑角色的接口
export function bjJe(id, data) {
    return request({
        url: `/roles/${id}`,
        method: 'PUT',
        data
    })
}

//更新角色权限的接口
export function gengXjs(roleId, rids) {
    return request({
        url: `roles/${roleId}/rights`,
        method: 'post',
        data: { rids }
    })
}

//获取商品列表的数据接口
export function getGoods(params) {
    return request({
        url: '/goods',
        method: 'get',
        params
    })
}

//删除单个商品
export function delOne(id) {
    return request({
        url: `/goods/${id}`,
        method: 'delete',

    })
}

//商品分类
export function getCatel(type = 3) {
    return request({
        url: '/categories',
        method: 'get',
        params: { type }

    })
}

// 商品列表商品分类数据列表
export function getgoodscategoriesApi(params) {
    return request({
        url: "/categories",
        method: "get",
        params
    })
}

//绘图接口
export function getSJ() {
    return request({
        url: '/reports/type/1',
        method: 'get',


    })
}

//获取参数列表接口
export function getCshu(id, sel = 'many') {
    return request({
        url: `categories/${id}/attributes`,
        method: 'get',
        params: { sel }

    })
}

//添加商品接口
export function getShangPing(data) {
    return request({
        url: `goods`,
        method: 'post',
        data

    })
}